<?php

/**
 * DZTAddress form base class.
 *
 * @method DZTAddress getObject() Returns the current form's model object
 *
 * @package    DZTidjara
 * @subpackage form
 * @author     Amine KHIAT
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDZTAddressForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                 => new sfWidgetFormInputHidden(),
      'address'            => new sfWidgetFormInputText(),
      'additional_address' => new sfWidgetFormInputText(),
      'number'             => new sfWidgetFormInputText(),
      'road'               => new sfWidgetFormInputText(),
      'zip_code'           => new sfWidgetFormInputText(),
      'city'               => new sfWidgetFormInputText(),
      'country'            => new sfWidgetFormInputText(),
      'is_active'          => new sfWidgetFormInputCheckbox(),
      'created_at'         => new sfWidgetFormDateTime(),
      'updated_at'         => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                 => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'address'            => new sfValidatorString(array('max_length' => 255)),
      'additional_address' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'number'             => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'road'               => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'zip_code'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'city'               => new sfValidatorString(array('max_length' => 255)),
      'country'            => new sfValidatorString(array('max_length' => 255)),
      'is_active'          => new sfValidatorBoolean(array('required' => false)),
      'created_at'         => new sfValidatorDateTime(),
      'updated_at'         => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'DZTAddress', 'column' => array('address')))
    );

    $this->widgetSchema->setNameFormat('dzt_address[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DZTAddress';
  }

}
